<script setup lang="ts">
import { SwitchButton } from '@element-plus/icons-vue';
const router = useRouter();
const route = useRoute();
const currentHighlightMenu = computed(() => route.path);

const handleExit = () => {
  useUserStore().exitLogin();
  router.replace('/login');
};
</script>

<template>
  <tab-bar></tab-bar>
  <el-container class="main-box">
    <el-aside style="width: 64px">
      <el-menu
        router
        :default-active="currentHighlightMenu"
        :collapse="true"
        style="min-height: 100%">
        <el-menu-item index="/home">
          <i class="iconfont icon-home"></i>
        </el-menu-item>
        <el-menu-item index="/chat">
          <i class="iconfont icon-whatsapp"></i>
        </el-menu-item>
      </el-menu>
      <el-icon class="exit-btn" :size="25" title="退出" @click="handleExit"
        ><SwitchButton
      /></el-icon>
    </el-aside>
    <el-main style="--el-main-padding: 0">
      <router-view v-slot="{ Component }">
        <keep-alive>
          <component :is="Component" />
        </keep-alive>
      </router-view>
    </el-main>
  </el-container>
</template>

<style lang="scss" scoped>
.cus-scrollbar {
  :deep(.el-scrollbar__view) {
    height: 100%;
  }
}

:deep(.el-menu-item) {
  .iconfont {
    font-size: 26px;
  }
  &:hover {
    .iconfont {
      transform: scale(1.2);
    }
  }
}

.main-box {
  height: calc(100vh - 31px);
}
.exit-btn {
  position: absolute;
  bottom: 10px;
  left: 16px;
  cursor: pointer;
}
</style>
